﻿using System;
using System.Linq.Expressions;
using System.Reflection;
using System.Security.Claims;
using System.Threading.Tasks;
using AntDesign.TableModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using NewLife.Reflection;
using SageKing.Blazor.OpenIdService.Components.Application.Pages.Manage.Components;
using static System.Runtime.InteropServices.JavaScript.JSType;
using Icon = AntDesign.Icon;

namespace SageKing.Blazor.OpenIdService.Components.Base;

public abstract class AuthComponentTabLeftBase<T, K, M> : AuthComponentTabTableBase<T, K>
      where T : IEntityBaseId<K>, new()
      where M : IModal<T>, new()
{

    #region Inject 相关
    //主表
    [Inject]
    public M MainEditModal { get; set; }
    #endregion

    #region Init
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        await InitModal();
    }


    public virtual async Task InitModal()
    {
        InitMainEditModal();

        await Task.CompletedTask;
    }
    public virtual void InitMainEditModal()
    {
        MainEditModal.Error = Error;
        MainEditModal.TabTitle = TabTitle;
    }

    #endregion 

    public override async Task EditModelValue<TT>(CellData<TT> cellData, string filedName)
    {
        //await base.EditOnStatusSwitch(cellData, filedName);
        var t = cellData.RowData.GetRowData<T>();
        await MainEditModal.EditOnStatusSwitch(t);
        //OnModelChangedAction(t, ChangedEnum.Modified);
    }
}
